package com.exam.controller;

import com.exam.entity.*;
import com.exam.serviceimpl.LoginServiceImpl;
import com.exam.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RegisterController {
    @Autowired
    private LoginServiceImpl loginService;
    @PostMapping("/register")
    public ApiResult register(@RequestBody Login login) {
        System.out.println(login.getUsername());
        System.out.println(login.getPassword());
        int res = loginService.studentRegister(login);
        if (res == 1) {
            return ApiResultHandler.buildApiResult(200, "注册成功", res);
        } else {
            return ApiResultHandler.buildApiResult(400, "注册失败", res);
        }
    }
}
